#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
using LL = long long;

int t, n;
const int N = 300010;
LL a[N], s[N];
bool st[N];

int main()
{
    cin >> t;
    while(t--)
    {
        cin >> n;
        s[0] = 0;
        for(int i = 1; i <= n; ++i)
            cin >> a[i], s[i] = s[i - 1] + a[i];
        // 首先，可以知道的是对于前缀和序列，该题目中的操作相当于交换两个序列
        LL s0 = s[0], sn = s[n];
        if(sn < s0) swap(s0, sn);
        sort(s, s + n + 1);
        for(int i = 0; i <= n; ++i)
        {
            if(s[i] == s0)
            {
                s0 = i;
                break;
            }
        }
        for(int i = 0; i <= n; ++i)
        {
            if(s[i] == sn && i != s0)
            {
                sn = i;
                break;
            }
        }
        memset(st, 0, sizeof st);
        int l = 0, r = n;
        for(int i = s0; i >= 0; i -= 2)
        {
            a[l++] = s[i];
            st[i] = true;
        }
        
        for(int i = sn; i <= n; i += 2)
        {
            a[r--] = s[i];
            st[i] = true;
        }
        
        for(int i = 0; i <= n; ++i)
        {
            if(!st[i])
                a[l++] = s[i];
        }
        LL ans = 0;
        for(int i = 1; i <= n; ++i)
            ans = max(ans, abs(a[i] - a[i - 1]));
        cout << ans << endl;
            
    }
    return 0;
}